package com.gxa.modules.pc.order.controller;

import com.gxa.common.utils.Result;
import com.gxa.common.utils.TPage;
import com.gxa.modules.model.dto.ScheduleDTO;
import com.gxa.modules.pc.order.service.BookRegisterService;
import com.gxa.modules.pc.order.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 医生日程安排表 前端控制器
 * </p>
 *
 * @author zhuiyi
 * @since 2022-11-13 12:10:47
 */
@RestController
@Api(tags = "医生排班")
@Slf4j
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation("查询所有  医生排班")
//    @RequiresPermissions("sys:user:list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "departmentId",value = "科室id",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "doctorName",value = "医生名字",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "week",value = "周 0-本周 -1 上周 -2 上上周 1 下周",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "pageNum",value = "当前在那一页",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "pageSize",value = "每页多少条记录",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "orderField",value = "根据什么字段排序",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "order",value = "升序-asc 降序-desc （不是asc都是降序）",dataType = "String"),
    })
    @GetMapping("/schedule/list")
    public Result list(@RequestParam @ApiIgnore HashMap<String,Object> searchMap){
        log.info("---------------{}-------------",searchMap);
        TPage tPage = scheduleService.queryByPage(searchMap);
        return new Result().ok(tPage);
    }

    @PutMapping("/schedule/update")
    @ApiOperation("修改  排班")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "departmentId",value = "科室id",dataType = "int",required = true),
            @ApiImplicitParam(paramType = "query",name = "doctorName",value = "医生名字",dataType = "String",required = true),
            @ApiImplicitParam(paramType = "query",name = "pageNum",value = "当前在那一页",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "pageSize",value = "每页多少条记录",dataType = "int"),
            @ApiImplicitParam(paramType = "query",name = "orderField",value = "根据什么字段排序",dataType = "String"),
            @ApiImplicitParam(paramType = "query",name = "order",value = "升序-asc 降序-desc （不是asc都是降序）",dataType = "String"),
    })
    public Result update(@RequestParam @ApiIgnore HashMap<String,Object> searchMap, @RequestBody List<ScheduleDTO> scheduleList){
        log.info("---------------{}-----{}--------",searchMap,scheduleList);
        scheduleService.deleteAndSave(searchMap,scheduleList);
        return new Result().ok();
    }


}
